// OUTDOOR SECTION SCRIPT
//    Section: X = 0, Y = 0

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

beginoutdoorscript;

variables;

short choice;

body;

beginstate INIT_STATE;
// This state called whenever this section is loaded into memory.
break;

beginstate START_STATE;
// Starting state of the section, called every turn the party 
// stands inside this section until you change the state.
break;

beginstate 10;
	if (get_flag(50, 2) > 0) {
		if (get_flag(50, 3) == 0) {
			if (get_flag(200, 0) == 0) {
				message_dialog("This must be the rock Jane told you about.  You start poking around in a large crack in the face of the rock.", "As you do a large wormlike creature appears and attacks.  It brought friends!");
				create_out_spec_enc(0);
			}
			else {
				message_dialog("You poke around in the crack some more, but find nothing else other than the bracelet you already have.", "Perhaps you should return it to Jane.");
			}
		}
		else {
			// show a message one more time, nothing here...
			if (get_flag(200, 1) == 0) {
				set_flag(200, 1, 1);
				message_dialog("You poke around in the crack in the rock, but you find nothing more.", "Luckily for you, nothing springs out of it also.");
			}
		}
	}
break;

beginstate 11;
	play_sound(142);
	reset_dialog();
	add_dialog_str(0, "The worm and it's friends are dead after a hard fought battle.", 0);
	add_dialog_str(1, "You clean up and continue poking around in the rock crack.", 0);
	add_dialog_str(2, "You find a bracelet deep inside, which with a little prying, you are able to retrieve.", 0);
	add_dialog_str(3, "This looks like the bracelet Jane described.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(0);
	change_spec_item(2, 1);
break;

beginstate 12;
	block_entry(1);
	if (get_flag(50, 1) > 0) {
		// we don't need Ben's introduction talk anymore
		set_flag(200, 2, 1);
	}
	if (get_flag(200, 2) == 0) {
		set_state_continue(13);
	}
	else {
		set_state_continue(14);
	}
break;

beginstate 13;
	set_flag(200, 2, 1);
	reset_dialog();
	add_dialog_str(0, "As you enter the camp, Ben jumps up from in front of the fire.", 0);
	add_dialog_str(1, "_Thank you for coming._ he says.  _I wasn't sure if you were really going to make it._", 0);
	add_dialog_str(2, "Ben adds _I have additional information.  It seems as if the she-devil is looking for something._", 0);
	add_dialog_str(3, "_What, no one knows.  But perhaps it will help you in dealing with her._", 0);
	add_dialog_str(4, "After a little more chit-chat, Ben thanks you again and wishes you luck in dealing with the she-devil.", 0);
	add_dialog_str(5, "_Mayor Clune in Cresent Harbor may know more information considering he's also the empire's garrison commander._", 0);
	add_dialog_str(6, "_Please come back and let me know when you have dealt with her._ Ben says as you prepare to leave.", 0);
	add_dialog_str(7, "You step away from the camp leaving a hopeful Ben staring into the flames of the campfire.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(1);
break;

beginstate 14;
	if (get_flag(50, 1) == 0) {
		set_state_continue(15);
	}
	else {
		set_state_continue(16);
	}
break;

beginstate 15;
	reset_dialog();
	add_dialog_str(0, "Ben looks up hopefully from in front of his campfire.", 0);
	add_dialog_str(1, "You see the hope fade from his face as he realizes you are not there with good news.", 0);
	add_dialog_str(2, "He offers you some food and rest as you go over your adventures so far.", 0);
	add_dialog_str(3, "After a while, you rise and continue on with your quest.", 0);
	add_dialog_str(4, "_Good luck._ Ben says before settling back down in front of the campfire.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(0);
	set_ticks_forward(50);
break;

beginstate 16;
	if (get_flag(200, 3) == 0) {
		set_state_continue(17);
	}
	else {
		set_state_continue(18);
	}
break;

beginstate 17;
	set_flag(200, 3, 1);
	reset_dialog();
	add_dialog_str(0, "Ben looks up hopefully from in front of his campfire.", 0);
	add_dialog_str(1, "When he hears that you have dealt with the she-devil, he jumps around with joy.", 0);
	add_dialog_str(2, "_Thank you, thank you._ he says over and over again.", 0);
	add_dialog_str(3, "_This is a good day for all of the Cresent Valley citizens._", 0);
	add_dialog_str(4, "Ben excitedly asks about the details, which you fill him in on.", 0);
	if (get_flag(50, 9) > 0) {
		add_dialog_str(5, "You tell him you killed her, but felt it somehow could've been avoided.", 0);
		add_dialog_str(6, "Ben doesn't seem fazed by the news.", 0);
	}
	else {
		add_dialog_str(5, "You tell him about finding the she-devils doll which was taken from her in Avernum.", 0);
		add_dialog_str(6, "When you returned it, she returned back to her home in the underworld.", 0);
	}
	add_dialog_str(7, "You fill Ben in with some more details, the get up to leave.", 0);
	add_dialog_str(8, "Ben continues to dance around the fire as you leave the camp.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(1);
	award_party_xp(200, 30);
	toggle_quest(0, 0);
break;

beginstate 18;
	reset_dialog();
	add_dialog_str(0, "Ben is still at his camp partying down at the news the she-devil is gone.", 0);
	add_dialog_str(1, "You stop and chat for a few moments, then leave Ben to his celebration.", 0);
	add_dialog_str(2, "The noise of it follows you out of the camp as you leave.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(0);
break;
